package co.edu.usbcali.museo.modelo.dto;

import co.edu.usbcali.museo.modelo.Autor;
import co.edu.usbcali.museo.presentation.backEndBeans.AutorView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura,
*
*/
public class AutorDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String nombreautor;
    private String codautor;
    private boolean rowSelected = false;
    private AutorView autorView;
    private Autor autor;

    public Autor getAutor() {
        return autor;
    }

    public String listener_update(ActionEvent e) {
        try {
            autorView.action_modifyWitDTO(((codautor == null) ||
                codautor.equals("")) ? null : new Long(codautor),
                ((nombreautor == null) || nombreautor.equals("")) ? null
                                                                  : new String(
                    nombreautor));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        codautor = autor.getCodautor().toString();
        nombreautor = (autor.getNombreautor() != null)
            ? autor.getNombreautor().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        codautor = autor.getCodautor().toString();
        nombreautor = (autor.getNombreautor() != null)
            ? autor.getNombreautor().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setAutor(Autor autor) {
        this.autor = autor;
    }

    public AutorView getAutorView() {
        return autorView;
    }

    public void setAutorView(AutorView autorView) {
        this.autorView = autorView;
    }

    public String getNombreautor() {
        return nombreautor;
    }

    public void setNombreautor(String nombreautor) {
        this.nombreautor = nombreautor;
    }

    public String getCodautor() {
        return codautor;
    }

    public void setCodautor(String codautor) {
        this.codautor = codautor;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
